import request from '@/utils/request'

// 分页查询
export function getDepartmentPage(params: any) {
  return request.get('/api/staff/departments/page', { params })

}

// 新增部门
export function addDepartment(data: any) {
  return request.post('/api/staff/departments', data)
}

// 编辑部门
export function updateDepartment(data: any) {
  return request.put('/api/staff/departments', data)
}

// 删除部门
export function deleteDepartment(id: number) {
  return request.delete(`/api/staff/departments/${id}`)
}

// 更新部门状态
export function updateDepartmentStatus(id: number, status: number) {
  return request.put(`/api/staff/departments/status/${id}?status=${status}`)
}

// 获取部门下的用户列表
export function getUsersByDepartment(id: number) {
  return request({
    url: `/api/staff/departments/${id}/users`,
    method: 'get'
  })
}
